from PIL import Image, ImageDraw

# 棋盘格的大小和颜色
height = 5
width= 7
square_size = 200
white = (255, 255, 255)
black = (0, 0, 0)

# 创建一个新的图像
image = Image.new("RGB", (width * square_size, height * square_size))

# 创建一个可以在图像上绘制的对象
draw = ImageDraw.Draw(image)

# 绘制棋盘格
for i in range(width):
    for j in range(height):
        upper_left = (i * square_size, j * square_size)
        lower_right = ((i + 1) * square_size, (j + 1) * square_size)
        if (i + j) % 2 == 1:
            draw.rectangle([upper_left, lower_right], fill=white)
        else:
            draw.rectangle([upper_left, lower_right], fill=black)

# 保存图像
image.save("checkerboard/checkerboard_"+str(width)+"x"+str(height)+".png")